home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 35 / Amiga Format AFCD35 (Issue 119, Jan 1999).iso / -in_the_mag- / reader_requests / fredobbutils / bbsrc / bootdir.s < prev    next >
Text File  |  1998-11-06  |  8KB  |  438 lines

  1. * Bootblock Spécial:    BootDir V2.0
  2. * Coded by Frédo (June '95)
  3. *
  4. * ESC pour sortir (boot normal)
  5. * ESPACE/RETOUR pour Avancer/Reculer
  6. * RETURN pour lire le répertoire racine (on peut changer de disk)
  7. *
  8. * Maintenir le bouton GAUCHE de la souris pendant le boot pour ne pas
  9. * exécuter le programme
  10. *
  11. *
  12. * FOR THE ENGLISH-SPEAKING:
  13. * this bootblock displays the root directory of the disk it's installed on.
  14. * this appeared useful to me, especially when i had no harddisk.
  15. * It was coded to be as system-friendly as possible.
  16. * Display may be buggy when filenames are too long, and some other bugs
  17. * may exist.
  18. *
  19. * the keys:
  20. * ESC to exit, SPACE/BACKSPACE to "navigate" through the pages
  21. * RETURN to reread the directory (you can even change the disk before that)
  22. * Hold the LEFT mouse button to skip the program.
  23.  
  24.     incdir    asm:/Include/
  25.     include    equ.s
  26.  
  27.     rsreset
  28. diskio    rs.l    1
  29. gfxbase    rs.l    1
  30. intbase    rs.l    1
  31. scrhd    rs.l    1
  32. scrwidth rs.w    1
  33. scrheight rs.w    1
  34. rport    rs.l    1
  35. font    rs.l    1
  36. fonty    rs.w    1
  37. fontx    rs.w    1
  38. buf    rs.l    1
  39. lastblk    rs.l    1
  40. VARSIZE    rs.w    0
  41.  
  42. BUFSIZE=$800
  43. XSTART=1
  44. YSTART0=18
  45. YSTART=YSTART0+8
  46. STATX=400
  47. VOLPEN=2
  48. DIRPEN=3
  49. FILEPEN=1
  50.  
  51.  
  52. ;DBUG=0    ;comment this to disable debug mode (when installing the bootblock)
  53.  
  54.     IFD    DBUG
  55.     move.l    4.w,a6
  56.     move.l    $9c(a6),d7    ;execbase->gfxbase
  57.     bra    RootDir
  58.     ENDC
  59.  
  60. Start:
  61.     dc.b    "DOS",0
  62.     dc.b    "SUM",0
  63. root    dc.l    $370    ;rootblock
  64.  
  65. Main:
  66.     btst    #6,$bfe001    ;Lefmousebutton held?
  67.     beq.s    Init        ;if yes, skip dir
  68.  
  69.     movem.l    d0-a6,-(sp)
  70. ;    move.l    $9c(a6),a6    ;execbase->gfxbase
  71. ;    move.l    a6,d7
  72. ;    moveq    #40,d6
  73. ;.wait    jsr    WaitTOF(a6)
  74. ;    dbf    d6,.wait
  75.  
  76.     bsr.s    RootDir
  77.     movem.l    (sp)+,d0-a6
  78. Init
  79.     lea    dosname(pc),a1
  80.     move.l    #"dos.",(a1)
  81.     jsr    FindResident(a6)
  82. ;    tst.l    d0
  83. ;    beq.b    .err
  84.     move.l    d0,a0
  85.     move.l    22(a0),a0
  86.     moveq    #0,d0
  87.     rts
  88. ;.err    moveq    #-1,d0
  89. ;    rts
  90.  
  91. * Directory du bloc racine en utilisant le trackdisk.device
  92. * Display the root directory of the disk, using trackdisk.device
  93. RootDir:
  94.     move.l    a1,a4        ;disk ioreq en A1
  95.     lea    -VARSIZE(sp),sp    ;alloc. variables on the stack
  96.     move.l    sp,a5
  97.     move.l    a4,(a5)        ;sauver ioreq
  98.  
  99.     IFD    DBUG
  100.     lea    diskport(pc),a1
  101.     move.l    a1,a4
  102.     move.l    4.w,a6
  103.     move.l    276(a6),$10(a1)
  104.     jsr    AddPort(a6)
  105.     lea    diskreq(pc),a1
  106.     move.l    a1,(a5)
  107.     move.l    a4,14(a1)
  108.     moveq    #0,d0
  109.     moveq    #0,d1
  110.     lea    trackname(pc),a0
  111.     jsr    OpenDevice(a6)
  112.     tst.l    d0
  113.     bne.w    .FreeVars
  114.     ENDC
  115.  
  116. .openint
  117.     move.l    $9c(a6),d7    ;execbase->gfxbase
  118.     move.l    d7,gfxbase(a5)
  119.     lea    intname(pc),a1
  120.     move.l    4.w,a6
  121.     jsr    -408(a6)
  122.     move.l    d0,intbase(a5)
  123.     move.l    d0,a6
  124. * Ouvrir écran, charger palette..
  125. * set up screen
  126. .openscr
  127.     lea    newscr(pc),a0
  128.     pea    title(pc)
  129.     move.l    (sp)+,20(a0)
  130.     jsr    OpenScreen(a6)
  131.     move.l    d0,scrhd(a5)
  132.     beq.w    .clint
  133.     move.l    d0,a3
  134.     lea    44(a3),a0
  135.     lea    mypal(pc),a1    ;my palette
  136.     moveq    #4,d0        ;colorcount
  137.     move.l    d7,a6
  138.     jsr    LoadRGB4(a6)
  139.     move.l    a3,a0
  140.     move.l    12(a0),scrwidth(a5)
  141.     lea    84(a0),a1
  142.     move.l    a1,rport(a5)
  143.     move.l    a1,a3
  144.     moveq    #0,d0
  145.     move.l    d0,d1
  146.     jsr    SetDrMd(a6)
  147.     lea    topaz.textattr(pc),a0
  148.     move.l    154(a6),a1    ;gfxbase DefaultFont
  149.     move.l    10(a1),(a0)    ;font name
  150.     jsr    OpenFont(a6)
  151.     move.l    d0,font(a5)
  152.     beq.s    .nofont
  153. .ok    move.l    d0,a0
  154.     move    20(a0),fonty(a5)
  155.     move    24(a0),fontx(a5)
  156.     move.l    a3,a1
  157.     jsr    SetFont(a6)
  158. .nofont
  159. * allocate buffer and display directory
  160. .dir
  161.     move.l    #BUFSIZE,d0
  162.     move.l    #$10002,d1
  163.     move.l    4.w,a6
  164.     jsr    AllocMem(a6)
  165.     move.l    d0,buf(a5)
  166.     beq.w    .nobuf
  167. .getroot
  168.     move.l    root(pc),d0    ;root blk
  169.     bsr.w    ReadBlk
  170.     bne.w    .clall        ;err?
  171.  
  172.     move.l    buf(a5),a0
  173.     move.l    a0,a4
  174.     moveq    #2,d0        ;type: short
  175.     cmp.l    (a0),d0
  176.     bne.w    .clall
  177.     moveq    #1,d0        ;sec.type: root
  178.     cmp.l    508(a0),d0
  179.     bne.w    .clall
  180.     move.l    12(a0),d0    ;hashtable size-1
  181.     subq.l    #1,d0
  182.     lea    24(a0),a0
  183.     move.l    buf(a5),a3
  184.     lea    $200(a3),a3
  185.     move.l    a3,a2
  186.     moveq    #0,d7
  187. .cop    move.l    (a0)+,d1
  188.     beq.b    .no
  189.     move.l    d1,(a3)+
  190.     addq    #1,d7        ;nbre d'entrées
  191. .no    dbf    d0,.cop
  192.     subq    #1,d7
  193.     move.l    a4,a3
  194. * écrire nom du disk (print diskname)
  195.     moveq    #XSTART,d5
  196.     moveq    #YSTART,d6
  197.  
  198.     lea    $1b0(a4),a4
  199.     moveq    #0,d3
  200.     move.b    (a4)+,d3
  201.     move    d5,d0
  202.     moveq    #YSTART0,d1
  203.     moveq    #VOLPEN,d2        ;pen
  204.     bsr.w    print
  205.  
  206.     move.l    a2,lastblk(a5)
  207. .exam
  208.     moveq    #$45,d4        ;ESC=exit
  209.     bsr.w    GetRawCode
  210.     cmp.b    d0,d4
  211.     beq.w    .abort
  212.  
  213.     move.l    (a2)+,d0    ;block #
  214. .chain
  215.     bsr.w    ReadBlk        ;read block
  216.     bne.w    .clall        ;si read err -> fin
  217. * afficher les noms de fichiers
  218. * display filenames
  219. .aff
  220.     move.l    buf(a5),a0
  221.     moveq    #-3,d0
  222.     moveq    #2,d1
  223.     cmp.l    (a0),d1
  224.     bne.b    .nofilesysblk
  225.     cmp.l    508(a0),d0
  226.     beq.b    .file
  227.     moveq    #DIRPEN,d2        ;pen color for dirs
  228.     bra.b    .aff2
  229. .file
  230.     moveq    #FILEPEN,d2        ;pen color for files
  231. .aff2
  232.     lea    $1b0(a0),a4
  233.     moveq    #0,d3
  234.     move.b    (a4)+,d3    ;name length in d3
  235.     move    d5,d0
  236.     move    d6,d1
  237.     bsr.w    print        ;print name
  238.     moveq    #29,d1
  239.     mulu    fontx(a5),d1
  240.     add    d1,d5
  241.     cmp    scrwidth(a5),d5
  242.     ble.b    .nxtline
  243.     moveq    #XSTART,d5
  244.     add    fonty(a5),d6
  245.     move    scrheight(a5),d0    ;screen height
  246.     sub    fonty(a5),d0
  247.     cmp    d0,d6
  248. ;    cmp    #100,d6
  249.     ble.b    .nxtline
  250.     bsr.w    Clr
  251.     moveq    #-1,d0
  252.     cmp.l    d0,d4
  253.     beq.b    .abort
  254. .nxtline
  255.     move.l    $1f0(a3),d0    ;hash chain?
  256.     bne.b    .chain
  257.     dbf    d7,.exam
  258. .nofilesysblk
  259.     bsr.w    MotOff        ;stop drive's motor
  260.  
  261. * wait for a key
  262. .wait
  263.     bsr.b    GetRawCode
  264.     cmp.b    #$44,d0        ;RETURN
  265.     bne.b    .back
  266. ;re-read dir
  267.     moveq    #YSTART0,d1
  268.     bsr.w    Clr2
  269.     bra.w    .getroot
  270. .back
  271.     cmp.b    #$41,d0        ;BACKSPACE
  272.     bne.b    .esc
  273.     moveq    #YSTART,d1
  274.     bsr.w    Clr2
  275.     move.l    lastblk(a5),a2
  276.     bra.w    .exam
  277. .esc    cmp.b    d0,d4
  278.     bne.b    .wait
  279. .abort
  280.     bsr.w    MotOff
  281.  
  282. * close and free all
  283. .clall
  284.     move.l    buf(a5),a1
  285.     move.l    #BUFSIZE,d0
  286.     move.l    4.w,a6
  287.     jsr    FreeMem(a6)
  288. .nobuf
  289. .clfnt
  290.     move.l    font(a5),d0
  291.     beq.b    .clscr
  292.     move.l    d0,a1
  293.     move.l    gfxbase(a5),a6
  294.     jsr    CloseFont(a6)
  295. .clscr
  296.     move.l    scrhd(a5),a0
  297.     move.l    intbase(a5),a6
  298.     jsr    CloseScreen(a6)
  299. .clint
  300.     move.l    intbase(a5),a1
  301.     move.l    4.w,a6
  302.     jsr    CloseLibrary(a6)
  303.  
  304.     IFD    DBUG
  305.     move.l    (a5),a1
  306.     move.l    14(a1),a4
  307.     jsr    CloseDevice(a6)
  308.     move.l    a4,a1
  309.     jsr    RemPort(a6)
  310.     ENDC
  311. .FreeVars
  312.     lea    VARSIZE(sp),sp    ;restore stack
  313. .end    rts
  314.  
  315. * get raw keycode
  316. GetRawCode
  317.     move.b    $bfec01,d0
  318.     ror.b    #1,d0
  319.     not.b    d0
  320.     rts
  321.  
  322. Clr:
  323.     movem.l    d0-d3/a0-a6,-(sp)
  324.     move.l    a2,d4
  325.     move    d5,d0
  326.     move    d6,d1
  327.     lea    moretxt(pc),a4
  328.     moveq    #VOLPEN,d2
  329.     moveq    #MORETXTLEN,d3
  330.     bsr.b    print
  331.     bsr.w    MotOff
  332. .w    bsr.b    GetRawCode
  333.     cmp.b    #$40,d0        ;SPACE
  334.     beq.b    .done
  335.     cmp.b    #$45,d0        ;ESC
  336.     beq.b    .exit
  337.     cmp.b    #$41,d0        ;BACKSPACE
  338.     bne.b    .w
  339.     move.l    lastblk(a5),d4
  340.     bra.b    .done
  341. .exit
  342.     moveq    #-1,d4
  343. .done
  344.     moveq    #YSTART,d1
  345.     bsr.b    Clr2
  346. .f    movem.l    (sp)+,d0-d3/a0-a6
  347.     move.l    d4,a2
  348.     rts
  349. Clr2
  350.     movem.l    d0-a6,-(sp)
  351.     moveq    #0,d0
  352.     bsr.b    Mov
  353.     jsr    ClearScreen(a6)
  354.     movem.l    (sp)+,d0-a6
  355.     moveq    #YSTART,d6
  356.     rts
  357. * Ecrire une ligne avec Text()
  358. * dans la couleur de son choix
  359. * <- a4: adr texte    d0: x    d1: y    d2: pen    d3: nbre de caract.
  360. print:
  361.     movem.l    d0-a6,-(sp)
  362.     bsr.b    Mov
  363.     move.l    a3,a1
  364.     move.l    d2,d0
  365.     jsr    SetAPen(a6)
  366.     move.l    a4,a0
  367.     move.l    d3,d0
  368.     move.l    a3,a1
  369.     jsr    Text(a6)
  370.     movem.l    (sp)+,d0-a6
  371.     rts
  372. Mov:
  373.     move.l    rport(a5),a1
  374.     move.l    a1,a3
  375.     move.l    gfxbase(a5),a6
  376.     jmp    Move(a6)
  377.  
  378. * Lire un block (read 1 disk block)
  379. * <-- d0: n° de block (block number)
  380. ReadBlk:
  381.     movem.l    d1-a6,-(sp)
  382.     move.l    (a5),a1
  383.     move.l    d0,d4
  384.     move    #2,28(a1)
  385.     move.l    #$200,36(a1)    ;io_length: 1 blk
  386.     move.l    buf(a5),40(a1)    ;io_data
  387.     moveq    #9,d1
  388.     lsl.l    d1,d4        ;io_offset=n°blk*512
  389.     move.l    d4,44(a1)
  390.     move.l    4.w,a6
  391.     jsr    DoIO(a6)
  392.     movem.l    (sp)+,d1-a6
  393.     tst.l    d0
  394.     rts
  395. * turn drive's motor off
  396. MotOff
  397.     move.l    (a5),a1
  398.     move    #9,28(a1)
  399.     clr.l    36(a1)
  400.     move.l    4.w,a6
  401.     jmp    DoIO(a6)
  402.  
  403. *** DATA
  404. newscr:
  405.     dc.w    0,0
  406.     dc.w    640,-1
  407.     dc.w    2
  408.     dc.b    0,1
  409.     dc.w    $8000
  410.     dc.w    $1    ;type
  411.     dc.l    0    ;topaz.textattr
  412.     dc.l    0    ;title
  413.     dc.l    0
  414.     dc.l    0
  415. mypal    dc.w    $bb9,$0,$fff,$0f0
  416. topaz.textattr
  417.     dc.l    0
  418.     dc.w    8
  419.     dc.b    0,0
  420.  
  421. intname    dc.b "intuit"
  422. dosname    dc.b "ion.library",0
  423. moretxt    dc.b "<BACK/SPACE> "
  424. MORETXTLEN=*-moretxt
  425. title    dc.b "BBDir 2.0 ©1995 Frédéric Bassaler",0
  426.  
  427.  dc.b "HOLD LEFTMOUSE DURING BOOT TO SKIP DIR."
  428.  
  429.     IFD    DBUG
  430. trackname    dc.b    "trackdisk.device",0
  431.     even
  432. diskport    dcb.b    34,0
  433. diskreq        dcb.b    56,0
  434.     ENDC
  435.  
  436. End:
  437.     dcb.b 512*2,0
  438.